# main.py
from engine import Trainer
from classes import log, CONFIG
import tkinter as tk

if __name__ == "__main__":
    try:
        trainer = Trainer()
        trainer.train()
        log.info("训练完成，模型已保存至: %s", CONFIG["save_dir"])
    except Exception as e:
        log.error("训练失败: %s", str(e))
    finally:
        if 'tk' in locals() and hasattr(tk, '_default_root') and tk._default_root is not None:
            log.info("绘图窗口保持打开，点击关闭按钮退出")
            tk._default_root.mainloop()